#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>

int main(int argc, char const *argv[])
{
        printf("Begin...\n");
        pid_t pid = fork();
        if(pid < 0){
                perror("fork error");
                exit(-1);
        }
        if(pid == 0){
                //子进程
                printf("I am a child, pid = %d, ppid = %d\n", getpid(), getppid());
        }else if(pid > 0){
                //父进程
                printf("child pid = %d, self pid = %d, ppid = %d\n ", pid, getpid(), getppid());
                sleep(1); 
        }
        printf("End...\n");
        return 0;
}
